package org.jwd.core.web;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * @author vizz
 * @since 2022/5/16 15:18
 * 返回的应答对象
 */
@Getter
@Setter
public class Res implements Serializable {

    private static final long serialVersionUID = 1L;
    private int code;
    private String msg;
    private Object data;

    public Res(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Res(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Res succeed(String msg) {
        return new Res(0, msg);
    }

    public static Res succeed(String msg, Object data) {
        return new Res(0, msg, data);
    }

    public static Res fail(int code, String msg) {
        return new Res(code, msg, null);
    }

    public static Res fail(int code, String msg, Object data) {
        return new Res(code, msg, data);
    }

}
